import defineReactiveData from "./reactive";
import { arrMthods } from './array';
import observerArr from './observerArr';

function Observer(data) {
    if (Array.isArray(data)) {
        data.__proto__ = arrMthods;
        observerArr(data);
    } else {
        this.walk(data);
    }
}

Observer.prototype.walk = function (data) {
    var keys = Object.keys(data);

    for (let i = 0; i < keys.length; i++) {
        var key = keys[i],
            value = data[key];

        defineReactiveData(data, key, value);
    }
}

export default Observer;